package com.mc.mcgoweb.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;

@SuppressWarnings("all")
public class TestJunit {
	

	
	/**
	 * 批量处理
	 * 修改运单状态
	 * @param args
	 * @throws ExecutionException 
	 * @throws InterruptedException 
	 *离线运单号获取
	 */
	public static void main(String[] args) {
	//  String jsonString = "{\r\n" + 
//	    "  \"appType\": \"2\",\r\n" + 
//	    "  \"compCode\": \"yimidida\",\r\n" + 
//	    "  \"workNum\": \"000488\",\r\n" + 
//	    "  \"password\": \"!q2w3e\"\r\n" + 
//	    "}";
//	  String jsonString = "{\r\n" + 
//	    "  \"appType\": \"2\",\r\n" + 
//	    "  \"compCode\": \"zongbu\",\r\n" + 
//	    "  \"workNum\": \"zongbu\",\r\n" + 
//	    "  \"password\": \"000000\"\r\n" + 
//	    "}";
//	  String url = "https://test111.yimidida.com/";
//	  String result = HttpRequestUtil.post(url+"galaxy-sso-business/login", jsonString);
//	  System.out.println("登录情况:"+result);
	  loginYH();

        HashMap<String, String> map = new HashMap<>();



        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entrie: entries){
            String waybillNo = entrie.getKey();
            String orderNo = entrie.getValue();
            System.out.println(">>>>>>>>>>>>>>>>>>>>>>手动推送TMS合同物流入参,运单号:{"+waybillNo+"},订单号:{"+orderNo+"}");
            String url = domainNameYHUrl+"galaxy-waybill-business/api/waybillForTms/sendWaybillInfo?waybillNo="+waybillNo+"&orderNo="+orderNo;
            String s = HttpRequestUtil.get(url);
            System.out.println(">>>>>>>>>>>>>>>>>>>>>>手动推送运单号:{"+waybillNo+"},订单号:{"+orderNo+"},返回结果:{"+s+"}");
        }

       //String result = HttpRequestUtil.get(domainNameYHUrl+"galaxy-waybill-business/api/waybillForTms/?num=250");

//	  ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(30));
//	  List<Object> waybillNoList = new JSONArray();
//	  List<ListenableFuture<JSONArray>> arrayList = new ArrayList<ListenableFuture<JSONArray>>();
//	  for (int i = 0; i < 100; i++) {
//		  ListenableFuture<JSONArray> submit = pool.submit(new Callable<JSONArray>() {
//
//			@Override
//			public JSONArray call() throws Exception {
//				try {
//					LOGGER.info("当前线程名{},获取运单号",Thread.currentThread().getName());
//					String result = HttpRequestUtil.get(domainNameYHUrl+"galaxy-waybill-business/api/waybillForTms/generateWaybillNos?num=250");
//					LOGGER.info("当前线程名{},结果:{}",Thread.currentThread().getName(),result);
//					JSONObject jsonObject = JSON.parseObject(result);
//					if(V.isNotEmpty(jsonObject.getJSONArray("data"))){
//						JSONArray jsonArray = jsonObject.getJSONArray("data");
//						if(jsonArray!=null){
//							return jsonObject.getJSONArray("data");
//						}
//					}
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//				return null;
//			}
//		});
//		  arrayList.add(submit);
//	  }
//	  pool.shutdown();
//	  for (ListenableFuture<JSONArray> listenableFuture : arrayList) {
//		  JSONArray jsonArray = listenableFuture.get();
//		if(jsonArray !=null){
//			LOGGER.info(">>>>>>>>>>>收集中.....");
//			waybillNoList.addAll(jsonArray);
//		}
//	  }
//	  LOGGER.info(">>>>>>>>>>>>获取运单号条数{}，运单号内容:{}",waybillNoList.size(),waybillNoList.toArray(new Long[waybillNoList.size()]));
	}
	
	private static String domainNameYHUrl="https://yh.yimidida.com/";
//	private static String domainNameYHUrl="https://galaxy.yimidida.com/";
	//private static String domainNameOfflineUrl="https://off-test.yimidida.com/";
	
	private static void loginYH(){
		 String jsonString = "{\r\n" +
				    "  \"appType\": \"2\",\r\n" +
				    "  \"compCode\": \"zongbu\",\r\n" +
				    "  \"workNum\": \"000488\",\r\n" +
				    "  \"password\": \"!q2w3e\"\r\n" +
				    "}";
//		 String jsonString = "{\r\n" +
//				    "  \"appType\": \"2\",\r\n" +
//				    "  \"compCode\": \"anhuisheng\",\r\n" +
//				    "  \"workNum\": \"040661\",\r\n" +
//				    "  \"password\": \"yimi753698!#$\"\r\n" +
//				    "}";
		  String url = domainNameYHUrl;
		  String result = HttpRequestUtil.post(url+"galaxy-sso-business/login", jsonString);
		  System.out.println("银河登录情况:"+result);
	}
	
//	private static void loginOffline(){
//		//{"compCode":"zongbu","workNum":"zongbu","password":"000000"}
//		String jsonString = "{" + 
//			    "  \"compCode\": \"zongbu\",\r\n" + 
//			    "  \"workNum\": \"zongbu\",\r\n" + 
//			    "  \"password\": \"000000\"\r\n" + 
//			    "}";
//	  String url = domainNameOfflineUrl;
//	  String result = HttpRequestUtil.post(url+"galaxy-offline-business/sys/offline/login", jsonString);
//	  System.out.println("离线系统登录情况:"+result);
//	}
	
//	private static void saveWaybillNoFileOut(List<Object> list){
//		 FileOutputStream fos=null;
//	        try {
//	            //创建输入流，并创建要写入的文件oldhappy.dt
//	            fos=new FileOutputStream(new File("D:\\offlineWaybillNos.txt"));
//	            //获取写入前的当前时间
//	            long l=System.currentTimeMillis();
//	            //格式化时间
//	            SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
//	            String time=s.format(l);
//	            //写入时间
//	            fos.write((time+"\r\n").getBytes());
//	            //写入要写的内容，并换行 
//	            //   \r\n表示换行
//	            for(int i=1;i<=10000;i++){
//	                fos.write(Arrays.toString(list.toArray(new Long[list.size()])).getBytes());
//	                fos.flush();
//	            }
//	            //获取写完后 时间
//	            long currentTime=System.currentTimeMillis();
//	            String time2=s.format(currentTime);
//	            fos.write(time2.getBytes());
//	        } catch (Exception e) {
//	            e.printStackTrace();
//	        }finally {
//	            if(fos!=null){
//	                try {
//	                    fos.close();
//	                } catch (IOException e) {
//	                    e.printStackTrace();
//	                }
//	            }
//	        }
//	}
}
